package cn.wolfcode.luowowo.scenic.domain;

import cn.wolfcode.luowowo.common.domain.BaseDomain;
import com.alibaba.fastjson.JSON;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.util.*;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ScenicDetail extends BaseDomain {

    public static final Integer STATE_OPEN = 0; //正常
    public static final Integer STATE_CLOSED = 1; //暂停营业

    //景点名字
    private String name;
    //景点标题
    private String title;
    //目的地ID
    private Long destId;
    //归属旅游景点
    private ScenicDetail parent;
    //概况
    private String summary;
    //封面图片引用
    private String coverUrl;
    /*//封面图片
     private String[] coverUrls;*/
    //电话
    private String tel;
    //网址
    private String website;
    //参考时间
    private String referenceTime;
    //交通
    private String transport;
    //开放时间
    private String openTime;
    //信息跟新时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date updateTime;
    //景点提示,tips
    private String tips;
    //景点状态
    private int state = ScenicDetail.STATE_OPEN;
    //评论数目
    private Integer replyNum;
    //是否热门
    private Boolean ishot;
    //收藏数
    private Integer favorNum = 0;
    //游玩人数
    private Integer visitorNum = 0;
    //子景点
    List<ScenicDetail> children = new ArrayList<>();
    //门票
    private Ticket ticket;
    //地址
    private String address;
    //主题
    private Long themeId;


    public String[] getCoverUrls() {
        String[] pics = null;
        if (StringUtils.hasLength(coverUrl)) {
            pics = coverUrl.split(",");
        }
        return pics;
    }

    /*   public String getCoverurl() {
           if (coverUrls == null) {
               return null;
           }

           StringBuilder sb = new StringBuilder();
           for (String pic : coverUrls) {
               sb.append(pic).append(",");
           }
           sb.deleteCharAt(sb.length() - 1);
           coverUrl = sb.toString();
           return coverUrl;
       }
   */
    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        return JSON.toJSONString(map);
    }

}